<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="archiving.html" />
<link rel="prev" href="crypto.html" />
<link rel="parent" href="lib.html" />
<link rel="next" href="module-os.path.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>11. 文件和目录访问</title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="10.4 sha  "
  href="module-sha.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="Python library Reference"
  href="lib.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="11.1 os.path  "
  href="module-os.path.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python库参考</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">前一节:</b>
<a class="sectref" rel="prev" href="module-sha.html">10.4 sha  </a>
<b class="navlabel">上一级:</b>
<a class="sectref" rel="parent" href="lib.html">Python库参考</a>
<b class="navlabel">下一节:</b>
<a class="sectref" rel="next" href="module-os.path.html">11.1 os.path  </a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h1><a name="SECTION0013000000000000000000"></a>
<a name="filesys"></a>
<br>
11. 文件和目录访问</h1>

<p>
这章中叙述处理磁盘文件和目录的模块。例如，有读取文件属性，用一种灵巧的方法操作路径，和创建临时文件的模块。这章中的模块完整的列表如下：
<p>
<table class='synopsistable' valign='baseline'>
  <tr class='oddrow'>
      <td><b><tt class='module'><a href='module-os.path.html'>os.path</a></tt></b></td>
      <td>&nbsp;</td>
      <td class='synopsis'>普通的路径名操作。</td></tr>
  <tr><td><b><tt class='module'><a href='module-fileinput.html'>fileinput</a></tt></b></td>
      <td>&nbsp;</td>
      <td class='synopsis'>多个输入流中类似于Perl的一行行迭代，和 ``save in place'' 一样的性能。</td></tr>
  <tr class='oddrow'>
      <td><b><tt class='module'><a href='module-stat.html'>stat</a></tt></b></td>
      <td>&nbsp;</td>
      <td class='synopsis'>解释 <tt class="function">os.stat()</tt>，<tt class="function">os.lstat()</tt>和<tt class="function">os.fstat()</tt>结果的实用程序。</td></tr>
  <tr><td><b><tt class='module'><a href='module-statvfs.html'>statvfs</a></tt></b></td>
      <td>&nbsp;</td>
      <td class='synopsis'>解释 <tt class="function">os.statvfs()</tt>结果的常量。</td></tr>
  <tr class='oddrow'>
      <td><b><tt class='module'><a href='module-filecmp.html'>filecmp</a></tt></b></td>
      <td>&nbsp;</td>
      <td class='synopsis'>高效率地比较文件。</td></tr>
  <tr><td><b><tt class='module'><a href='module-tempfile.html'>tempfile</a></tt></b></td>
      <td>&nbsp;</td>
      <td class='synopsis'>生成临时文件和目录。</td></tr>
  <tr class='oddrow'>
      <td><b><tt class='module'><a href='module-glob.html'>glob</a></tt></b></td>
      <td>&nbsp;</td>
      <td class='synopsis'><span class="Unix">Unix</span> shell 风格的路径名模式扩展。</td></tr>
  <tr><td><b><tt class='module'><a href='module-fnmatch.html'>fnmatch</a></tt></b></td>
      <td>&nbsp;</td>
      <td class='synopsis'><span class="Unix">Unix</span> shell 风格的文件名模式匹配。</td></tr>
  <tr class='oddrow'>
      <td><b><tt class='module'><a href='module-linecache.html'>linecache</a></tt></b></td>
      <td>&nbsp;</td>
      <td class='synopsis'>这个模块提供从文本文件中随机访问单行。</td></tr>
  <tr><td><b><tt class='module'><a href='module-shutil.html'>shutil</a></tt></b></td>
      <td>&nbsp;</td>
      <td class='synopsis'>高级文件操作，包括复制。</td></tr>
  <tr class='oddrow'>
      <td><b><tt class='module'><a href='module-dircache.html'>dircache</a></tt></b></td>
      <td>&nbsp;</td>
      <td class='synopsis'>以缓存机制返回目录列表。</td></tr>
</table>

<br>
<p>
对于Python的内置文件对象的描述也可以参见 <a href="bltin-file-objects.html#bltin-file-objects">3.9</a> 节。<p>
<div class="seealso">
  <p class="heading">也见：</p>

    <dl compact="compact" class="seemodule">
    <dt>模块 <b><tt class="module"><a href="module-os.html">os</a></tt>：</b>
    <dd>操作系统接口，包括工作在比内置的文件对象低级的文件上的函数。    
  </dl>
</div>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="10.4 sha  "
  href="module-sha.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="Python library Reference"
  href="lib.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="11.1 os.path  "
  href="module-os.path.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python库参考</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'><b class="navlabel">前一节:</b> <a class="sectref" rel="prev" href="module-sha.html">10.4 sha </a> <b class="navlabel">上一级:</b> <a class="sectref" rel="parent" href="lib.html">Python库参考</a> <b class="navlabel">下一节:</b> <a class="sectref" rel="next" href="module-os.path.html">11.1 os.path </a></div>
</div>
<hr />
<span class="release-info">2.5.1 版， 文档更新在 2007，4，18。翻译：<a href="http://www.zkfarmer.org">zkfarmer</a>。</span>
</div>
<!--End of Navigation Panel-->
<address>
关于建议修改的信息查阅 <i><a href="about.html">关于这个文档...</a></i>。
</address>
</body>
</html>
